<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
	<base href="${pageContext.request.contextPath}/">
<meta charset="UTF-8">
<link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
<script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function(){
			//整个浏览器窗口添加事件
			$(window).keydown(function(e){
				//如果按的是回车键，则提交登录请求
				if(e.keyCode == 13) {
					$("#loginButton").click();
				}
			})
			//单击“登录”按钮事件
			$("#loginButton").click(function() {
				let loginAct = $.trim($("#loginAct").val());
				let loginPwd = $.trim($("#loginPwd").val());
				let isRemPwd = $("#isRemPwd").prop("checked");
				//表单验证
				if (loginAct == "" || loginPwd == "") {
					alert("用户名或者密码不能为空！！！");
					return;
				}
				//发送请求
				$.ajax({
					url:'settings/qx/user/login.do',
					data:{
						loginPwd, loginAct, isRemPwd
					},
					type:'post',
					dataType:'json',
					success:function(data) {
						//登录成功
						if(data.code == "1") {
							$("#msg").text("");
							//跳转到业务主页面
							window.location.href = "workbench/index.do";
						}else {
							//登录失败,在原页面中提示信息
							$("#msg").text(data.message);
						}
					},
					beforeSend:function(){ //在发送ajax之前执行此函数，返回值会影响执行结果；
						$("#msg").text("正在验证……");
					}
				})
			})
		})
	</script>
</head>
<body>
	<div style="position: absolute; top: 0px; left: 0px; width: 60%;">
		<img src="image/IMG_7114.JPG"
			 style="width: 100%; height: 90%; position: relative; top: 50px;">
	</div>
	<div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
		<div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">&copy;2024&nbsp;无名子</span></div>
	</div>

	<div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
		<div style="position: absolute; top: 0px; right: 60px;">
			<div class="page-header">
				<h1>登录</h1>
			</div>
			<form action="workbench/index.html" class="form-horizontal" role="form">
				<div class="form-group form-group-lg">
					<div style="width: 350px;">
						<input class="form-control" id="loginAct" value="${cookie.loginAct.value}" type="text" placeholder="用户名">
					</div>
					<div style="width: 350px; position: relative;top: 20px;">
						<input class="form-control" id="loginPwd" value="${cookie.loginPwd.value}" type="password" placeholder="密码">
					</div>
					<div class="checkbox"  style="position: relative;top: 30px; left: 10px;">
						<label>
							<c:choose>
								<c:when test="${not empty cookie.loginAct and not empty cookie.loginPwd}">
									<input id="isRemPwd" type="checkbox" checked> 十天内免登录
								</c:when>
								<c:otherwise>
									<input id="isRemPwd" type="checkbox"> 十天内免登录
								</c:otherwise>
							</c:choose>

						</label>
						&nbsp;&nbsp;
						<span style="color:red" id="msg"></span>
					</div>
					<button type="button" id="loginButton" class="btn btn-primary btn-lg btn-block"  style="width: 350px; position: relative;top: 45px;">登录</button>
				</div>
			</form>
		</div>
	</div>
</body>
</html>
